use std::thread;
use std::time::Duration;

fn main() {
    example_164();
}

fn example_162(){
    let handle = thread::spawn(||{
        for x in 1..=15{
            thread::sleep(Duration::from_millis(2));
            println!("{:02} from spawned thread", x);
        }
    });

    for x in 1..=5{
        println!("{} from main thread", x);
        thread::sleep(Duration::from_millis(1));
    }
    handle.join().unwrap();
}

fn example_163(){
    let v = vec![1, 3, 5];
    let handle = thread::spawn(move ||{
        println!("{:?}", v);
    });
    handle.join().unwrap();
}

fn example_164(){
    let v = vec![1, 3, 5];
    let handle = thread::spawn(move ||{
        println!("{:?}", v);
    });
    // drop(v);// 由于v的所有权已经转移给了新的子线程，主线程中就无权对其进行新的操作了
    handle.join().unwrap();
}